﻿using Microsoft.Graphics.Canvas;
using Microsoft.Graphics.Canvas.Effects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace 纸片人.win2dEffectControl.DataClass
{
    public class MorphologyEffectData : EffectOneSourceData
    {
        #region  属性

        private Vector2 _effectSize = new Vector2(1, 1);

        private MorphologyEffectMode _mode;

        public Vector2 EffectSize
        {
            get => _effectSize;
            set
            {
                _effectSize = value;

                if (value.X < 1)
                {
                    _effectSize.X = 1;
                }
                if (value.Y < 1)
                {
                    _effectSize.Y = 1;
                }

                OnPropertyChanged();
                SetIsChanges();
            }
        }

        public MorphologyEffectMode Mode { get => _mode; set { _mode = value; OnPropertyChanged(); SetIsChanges(); } }


        #endregion

        public override ICanvasImage GetEffect(CanvasDevice device, bool compression)
        {
            var source = GetSourceEffect(device, compression);
            if (source == null)
            {
                return null;
            }
            var e = new MorphologyEffect();
            MorphologyEffect effect = new MorphologyEffect()
            {
                Height = (int)EffectSize.X,
                Width = (int)EffectSize.Y,
                Mode = Mode,
                Source = source
            };
          
       

            return effect;
        }
    }
}
